<include file="Public/min-header"/>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 订单统计</h3>
                </div>
                <div class="panel-body">
                    <div class="navbar navbar-default">
                        <form action="" id="search-form2" class="navbar-form form-inline" method="post">
                            <div class="form-group">
                            <!--<label class="control-label">选择教练:</label>-->
                            <select name="sales_id" id="sales_id" class="form-control" style="width:200px;">
                            <option value="">选择业务员</option>
                            <foreach name="sales_all" item="v" key="k" >
                            <option value="{$v['id']}"    <if condition="$v['id'] eq $sales_id">selected</if>   > {$v['name']}</option>
                            </foreach>
                            </select>
                            </div>
                            <div class="form-group">
                                <!--<label class="control-label"  >选择周期:</label>-->
                                <select name="date_id" id="date_id" class="form-control" style="width:200px;">
                                    <option value="0" >全部</option>
                                    <option value="1" <if condition="1 eq $date_id">selected</if>>今天</option>
                                    <option value="2" <if condition="2 eq $date_id">selected</if>>7天内</option>
                                    <option value="3" <if condition="3 eq $date_id">selected</if>> 本月</option>
                                    <option value="4" <if condition="4 eq $date_id">selected</if>> 近三个月</option>
                                    <option value="5" <if condition="5 eq $date_id">selected</if>>今年</option>
                                </select>
                            </div>


                            <div class="form-group">
                                <input type="hidden" name="order_by" value="user_id">
                                <input type="hidden" name="sort" value="desc">
                                <button type="submit" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary pull-right"><i class="fa fa-search"></i> 筛选</button>
                            </div>
                            <!--<button type="button" onclick="send_message(0);" class="btn btn-primary"><i class="fa"></i> 发送站内信</button>-->
                            <!--<button type="button" onclick="send_mail(0);" class="btn btn-primary"><i class="fa"></i> 发送邮箱</button>-->
                            <!--<a href="{:U('User/add_user')}" class="btn btn-info pull-right">添加会员</a>-->
                        </form>
                    </div>
                    <div  >

                        <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <td class="text-right"  style="width:8%;">排序</td>
                                        <td class="text-left"  style="width:20%;">业务员名称</td>
                                        <td class="text-left"  style="width:20%;">头像</td>
                                        <td class="text-left">订单数量</td>
                                        <td class="text-left">查看详情</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <volist name="lists" id="list">
                                        <tr>
                                            <td class="text-right">{$xuhao++}</td>
                                            <td class="text-left">{$list.name}</td>
                                            <td class="text-left"><img src="{$list.head_img}" style="height:50px;"/></td>
                                            <td class="text-left">{$list.count}</td>
                                            <td class="text-left"><a type="button" href="{:U('order_show',array('sales_id'=>$list[id]))}">查看详情</a></td>
                                        </tr>
                                    </volist>
                                    </tbody>
                                </table>
                            </div>
                        </form>
                        <div class="row">
                            <div class="col-sm-3 text-left">
                            </div>
                            <div class="col-sm-6 text-right">{$page}</div>
                        </div>
                        <script>
                            $(".pagination  a").click(function(){
                                var page = $(this).data('p');
                                ajax_get_table('search-form2',page);
                            });
                        </script>
                    </div>
                </div>
            </div>
        </div>        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script>
    $(document).ready(function(){
//        ajax_get_table('search-form2',1);

    });

    // ajax 抓取页面
    function ajax_get_table(tab,page){
        return;
        cur_page = page; //当前页面 保存为全局变量
        $.ajax({
            type : "POST",
            url:"/Admin/user/ajaxindex/p/"+page,//+tab,
            data : $('#'+tab).serialize(),// 你的formid
            success: function(data){
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
    }

    // 点击排序
    function sort(field)
    {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }

    //发送站内信
    function send_message(id)
    {
        var obj = $("input[name*='selected']");
        var url = "{:U('Admin/User/sendMessage')}";
        if(obj.is(":checked")){
            var check_val = [];
            for(var k in obj){
                if(obj[k].checked)
                    check_val.push(obj[k].value);
            }
            url += "?user_id_array="+check_val;
        }
        layer.open({
            type: 2,
            title: '站内信',
            shadeClose: true,
            shade: 0.8,
            area: ['580px', '480px'],
            content: url
        });
    }

    //发送邮件
    function send_mail(id)
    {
        var obj = $("input[name*='selected']");
        var url = "{:U('Admin/User/sendMail')}";
        if(obj.is(":checked")){
            var check_val = [];
            for(var k in obj){
                if(obj[k].checked)
                    check_val.push(obj[k].value);
            }
            url += "?user_id_array="+check_val;
            layer.open({
                type: 2,
                title: '发送邮箱',
                shadeClose: true,
                shade: 0.8,
                area: ['580px', '480px'],
                content: url
            });
        }else{
            layer.msg('请选择会员');
        }

    }

    /**
     * 回调函数
     */
    function call_back(v) {
        layer.closeAll();
        if (v == 1) {
            layer.msg('发送成功');
        } else {
            layer.msg('发送失败');
        }
    }


</script>
</body>
</html>